package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.TuiKuanKuaiDiBean;
import com.lwj.liwanjia.bean.WuLiuBean01;

import java.util.List;

/**
 * Created by 001 on 2017/9/22.
 */

public class TuiKuanKuaiDiAdapter extends RecyclerView.Adapter<TuiKuanKuaiDiAdapter.ViewHolder> {


    private Context mContext;
    private List<WuLiuBean01.ResultBean.ListBean> mList;

    public TuiKuanKuaiDiAdapter(Context mContext, List<WuLiuBean01.ResultBean.ListBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public TuiKuanKuaiDiAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_tui_kuan_kuai_di, parent, false);

        ViewHolder holder = new ViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(TuiKuanKuaiDiAdapter.ViewHolder holder, int position) {

        WuLiuBean01.ResultBean.ListBean bean = mList.get(position);

        holder.tv_content.setText(bean.getRemark());
        holder.tv_time.setText(bean.getDatetime());

        if (position == 0) {
            holder.iv_huiDian.setImageResource(R.mipmap.cheng_dian);
            holder.tv_content.setTextColor(Color.parseColor("#EC921A"));
        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        ImageView iv_huiDian;
        TextView tv_content;
        TextView tv_time;

        public ViewHolder(View itemView) {
            super(itemView);

            iv_huiDian = (ImageView) itemView.findViewById(R.id.iv_huiDian);
            tv_content = (TextView) itemView.findViewById(R.id.tv_content);
            tv_time = (TextView) itemView.findViewById(R.id.tv_time);
        }
    }
}
